package org.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.example.domain.entity.UserName;
import org.example.domain.model.Result;
import org.example.mapper.LoginNameMapper;
import org.example.service.ILoginNameService;
import org.springframework.stereotype.Service;

import java.util.HashMap;

import java.util.Map;

@Service
public class LoginNameServiceImpl implements ILoginNameService {

    private LoginNameMapper goodsMapper;

    public LoginNameServiceImpl(LoginNameMapper goodsMapper) {
        this.goodsMapper = goodsMapper;
    }

    @Override
    public Result selectAllName(Integer page, Integer limit) {
        Page<UserName> p = PageHelper.startPage(page, limit);

        goodsMapper.selectList(Wrappers.emptyWrapper());

        Map<String, Object> data = new HashMap<>();
        data.put("total", p.getTotal());
        data.put("users", p.getResult());
        return Result.buildSuccess(data);
    }
}
